package com.fs;

import com.fs.service.EmailService;
import com.fs.vo.RegisterSendEmailVO;
import com.fs.vo.ResultVO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@SpringBootTest
public class t1 {
    @Autowired
    private JavaMailSender javaMailSender;

    @Test
    public void t1(){
        Float s = new Float(0.1f);
        Float t = new Float(0.1f);
        Double u = new Double(0.1);
        System.out.println(s==t);
        System.out.println(s.equals(t));
        System.out.println(u.equals(s));
        System.out.println(t.equals(u));
    }
    @Test
    public void sendSimpleMail() {
        // 构建一个邮件对象
        SimpleMailMessage message = new SimpleMailMessage();
        // 设置邮件主题
        message.setSubject("这是一封测试邮件");
        // 设置邮件发送者，这个跟application.yml中设置的要一致
        message.setFrom("15234694770@163.com");
        // 设置邮件接收者，可以有多个接收者，中间用逗号隔开，以下类似
        // message.setTo("10*****16@qq.com","12****32*qq.com");
        message.setTo("1569023477@qq.com");
        // 设置邮件抄送人，可以有多个抄送人
//        message.setCc("12****32*qq.com");
        // 设置隐秘抄送人，可以有多个
//        message.setBcc("7******9@qq.com");
        // 设置邮件发送日期
        message.setSentDate(new Date());
        // 设置邮件的正文
        message.setText("这是测试邮件的正文");
        // 发送邮件
        javaMailSender.send(message);
    }


    @Autowired
    private EmailService emailService;

    @Test
    public void sendEmailService(){
        RegisterSendEmailVO vo = new RegisterSendEmailVO()
                .setEmail("2642384583@qq.com")
                .setTitle("注册成功")
                .setContent("您已注册成功");
        ResultVO resultVO = emailService.sendRegisterEmail("2642384583@qq.com",1);
        System.out.println(resultVO);
    }

}
